<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <el-row>
        <el-col :span="8">
          <el-input placeholder="请输入内容">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table :data="orderList" border stripe style="width: 100%">
         <el-table-column align="center" label="*" type="index" >
        </el-table-column>
        <el-table-column align="center" label="订单编号" prop="order_number" >
        </el-table-column>
        <el-table-column align="center" label="订单价格" prop="order_price" >
        </el-table-column>
        <el-table-column align="center" label="是否付款" >
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.pay_status === '1'">已付款</el-tag>
            <el-tag type="danger" v-else>未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="是否发货" prop="is_send" >
        </el-table-column>
        <el-table-column align="center" label="下单时间" >
          <template slot-scope="scope">
            <span>{{scope.row.create_time | time}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="操作">
          <template>
            <el-button  plain size="mini" type="primary" icon="el-icon-edit" @click="cityVisible = true"></el-button>
            <el-button  plain size="mini" type="primary" icon="el-icon-location-outline"></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页器 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="query.pagenum"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="query.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </el-card>
    <el-dialog
      title="提示"
      :visible.sync="cityVisible"
      width="50%"
      >
      <el-form>
        <el-form-item label="省市区/县" label-width="80px">
          <el-cascader
            v-model="selectCity"
            :options="cityData"
            @change="handleChange">
          </el-cascader>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cityVisible = false">取 消</el-button>
        <el-button type="primary" @click="cityVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import cityData from './citydata.js'

export default {
  name: 'Order',
  data () {
    return {
      query: {
        query: '',
        pagenum: 1,
        pagesize: 5
      },
      orderList: [], // 订单数据
      total: 0,
      cityVisible: false,
      cityData: cityData,
      selectCity: []

    }
  },
  created () {
    this.getOrder()
  },
  methods: {
    async getOrder () {
      const { data: res } = await this.$http.get('orders', {
        params: this.query
      })
      if (res.meta.status !== 200) {
        return this.$message.error(res.meta.msg)
      }
      this.$message.success(res.meta.msg)
      this.orderList = res.data.goods
      this.total = res.data.total
    },
    handleSizeChange (val) {
      this.query.pagesize = val
      this.getOrder()
    },
    handleCurrentChange (val) {
      this.query.pagenum = val
      this.getOrder()
    },
    handleChange () {}
  }
}
</script>

<style lang="less" scoped></style>
